//
//  YMVListTableViewCell.m
//  STL_ Animation
//
//  Created by DJtd on 16/4/4.
//  Copyright © 2016年 STL. All rights reserved.
//

#import "YMVListTableViewCell.h"

@implementation YMVListTableViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor blackColor];
        
        self.leftImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.title = [[UILabel alloc] initWithFrame:CGRectZero];
        self.singer = [[UILabel alloc] initWithFrame:CGRectZero];
        self.watchTimes = [[UILabel alloc] initWithFrame:CGRectZero];

        self.shareButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.shareButton setImage:[[UIImage imageNamed:@"bai"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
#warning bug---2
        self.shareButton.hidden = YES;
        self.title.textColor = [UIColor whiteColor];
        self.singer.textColor = [UIColor colorWithRed:8/255.0 green:146/255.0 blue:114/255.0 alpha:1];
        self.watchTimes.textColor = [UIColor lightGrayColor];
        
        self.title.font = [UIFont systemFontOfSize:12];
        self.singer.font = [UIFont systemFontOfSize:12];
        self.watchTimes.font = [UIFont systemFontOfSize:12];

        
        [self addSubview:self.leftImage];
        [self addSubview:self.title];
        [self addSubview:self.singer];
        [self addSubview:self.watchTimes];
        [self addSubview:self.shareButton];
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(0, 0, BoundsWidth / 5 * 2, BoundsHeight);
    self.title.frame = CGRectMake(BoundsWidth / 5 * 2 + 5, 5, BoundsWidth / 5 * 2, (BoundsHeight - 10) / 3);
    self.singer.frame = CGRectMake(BoundsWidth / 5 * 2 + 5, (BoundsHeight - 10) / 3 + 5, BoundsWidth / 5 * 2, (BoundsHeight - 10) / 3);
    self.watchTimes.frame = CGRectMake(BoundsWidth / 5 * 2 + 5, (BoundsHeight - 10) / 3 * 2 + 5, BoundsWidth / 5 * 2, (BoundsHeight - 10) / 3);
    self.shareButton.frame = CGRectMake(BoundsWidth - 45, BoundsHeight / 2 - 15, 40, 30);
}


- (void)setHomeModel:(HomePageBaseModel *)homeModel {
    _homeModel = homeModel;
    if ([homeModel.albumImg hasPrefix:@"http"]) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:homeModel.albumImg] placeholderImage:[UIImage imageNamed:@"YMVPlace1"]];
    } else if ([homeModel.thumbnailPic hasPrefix:@"http"]) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:homeModel.thumbnailPic] placeholderImage:[UIImage imageNamed:@"YMVPlace1"]];
    } else {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:homeModel.posterPic] placeholderImage:[UIImage imageNamed:@"YMVPlace1"]];
    }
    
    self.title.text = homeModel.title;
    self.singer.text = homeModel.artistName;
    self.watchTimes.text = [NSString stringWithFormat:@"播放次数:%@", homeModel.totalViews];
}


@end



